home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 846 b | 45 lines | [TEXT/CWIE] |
- // MethodOf.h
-
- #ifndef MethodOf_h
- #define MethodOf_h
-
- #ifndef Method_h
- #include "Method.h"
- #endif
- #ifndef Integers_h
- #include "Integers.h"
- #endif
-
- template < class TheTargetType >
- class MethodOf: public Method
- {
- typedef TheTargetType TargetType;
- typedef void (TargetType::*MemberType)();
-
- private:
- TargetType *target;
- MemberType method;
-
- public:
- MethodOf( TargetType *theTarget, MemberType theMethod )
- : target( theTarget ),
- method( theMethod )
- {}
-
- TargetType *Target() const { return target; }
- MemberType Method() const { return method; }
-
- void SetTarget( TargetType *t ) { target = t; }
- void SetMethod( MemberType m ) { method = m; }
-
- bool Null() const { return target == 0 || method == 0; }
-
- virtual void operator()() const
- {
- if ( !Null() )
- (target->*method)();
- }
- };
-
- #endif
-